﻿var BizDialog = function (selector, setts) {
    this.selector = selector;
    var $this = this;
    var defaultSetts = {
        resizable: $this.resizable,
        closed: $this.closed,
        cache: $this.cache,
        href: $this.href,
        modal: $this.modal
        //onBeforeOpen: $this.onBeforeOpen,
        //onClose: $this.onClose
    };
    setts = setts || {};
    $.extend(true, defaultSetts, setts);
    this.href = defaultSetts["href"];
    defaultSetts["href"] = "";
    this.source = $(this.selector);
    var $dialog = this.source;
    if (this.href && this.href != "") {
        $dialog.children().remove();
        $dialog.append(CreateiFrame(this.href));
    }
    $dialog.dialog(defaultSetts);
    //打开窗口
    this.open = function () {
        $dialog.dialog("open");
    };
    //关闭窗口
    this.close = function () {
        $dialog.dialog("close");
    };
    //刷新窗口
    this.refresh = function (href) {
        if (href && href != "") {
            $dialog.children().remove();
            $dialog.append(CreateiFrame(href));
            $dialog.dialog(defaultSetts);
            $dialog.dialog('refresh');
        } else {
            $dialog.dialog('refresh');
        }
    };

}
BizDialog.prototype = {
    //选择器
    selector: "",
    //是否可伸展
    resizable: true,
    //窗口状态，默认关闭状态
    closed: true,
    //缓存状态，默认关闭
    cache: false,
    //iframe链接
    href: "",
    //是否阴影背景
    modal: true,
    ////窗口打开前事件
    //onBeforeOpen: function () { },
    ////窗口关闭后事件
    //onClose: function () { }
};